/*
 * Copyright (C) 2012 Tomas Shestakov. <http://code.google.com/p/jmmo/>
 */

package jmmo.engine.grid

import scala.collection.mutable.Map
import scala.collection.Set
import jmmo.util.Cell

/**
 * It is intended for mixing with [[jmmo.engine.grid.MTBlockingGridData]]
 * instead of [[jmmo.engine.grid.STMapGridData]] for using Grid in parallel.
 *
 * ConcurrentHashMap getting 1 concurrencyLevel because
 * only one thread will modify and all others will only read from ConcurrentHashMap.
 * @author Tomas Shestakov
 * @tparam A type of object for adding to the Grid.
 */
trait MTConcMapGridData[A] extends STMapGridData[A] {

  import collection.JavaConversions._

  //only one thread will modify and all others will only read from ConcurrentHashMap
  protected override val innerMap: Map[Cell, Set[A]] = new java.util.concurrent.ConcurrentHashMap[Cell, Set[A]](16, 0.75f, 1)

}
